<?php if ($this->st_registry->registry('admin/catalog/chapter/message')) : ?>
    <div class="stdWidth autoCenter message">
        <?php echo $this->st_registry->getFlashMessage('admin/catalog/chapter/message'); ?>
    </div>
<?php endif; ?>
<?php $pagData = $paginator->getPages('slider'); ?>
<?php echo form_open_multipart('admin/catalog/chapter/index', array('id' => 'frmChapterGridView')); ?>
<?php echo fx_control::newInstance('formKey')->createType('hidden')->setData('value', random_string('unique', 16))->render(); ?>
<?php echo fx_control::newInstance('chapter_ids')->createType('hidden')->setData('value', $chapter_ids)->render(); ?>
    <input type="hidden" class="pageIndex" id="chapterPageIndex" value="<?php echo $paginator->getCurrentPageNumber() ?>" name="page"/>
    <div id="box">
        <div id="title">
            <h4><?php echo $module['title'] ?></h4>
        </div>
        <div id="toolBar">
            <ul>
                <li class="new"><a class="flashEditor" href="<?php echo site_url('admin/catalog/chapter/edit', true) ?>"><span>New</span></a></li>
                <li class="selectAll"><a href="#" onclick="return selectAll('chkChapter', 'chapter_ids', '<?php echo site_url('admin/grid/select/chapter_model',true)?>', 'chapterItemSelected', 'chapterSelectedValueHidden')"><span>Select All</span></a></li>
                <li><a href="#" onclick="return unSelectAll('chkChapter', 'chapter_ids', 'chapterItemSelected', 'chapterSelectedValueHidden')"><span>Unselect All</span></a></li>
                <li class="select"><a href="#" onclick="return selectVisible('chkChapter', 'chapter_ids', 'chapterItemSelected', 'chapterSelectedValueHidden')"><span>Select Visible</span></a></li>
                <li class="first"><a href="#" onclick="return unSelectVisible('chkChapter', 'chapter_ids', 'chapterItemSelected', 'chapterSelectedValueHidden')"><span>Unselect Visible</span></a></li>
            </ul>
        </div>
        <div id="informationTable">
            <div id="action">
                <input name="btnSubmit" type="submit" value="Search" class="btnBlue left"/>
                <input name="btnReset" type="button" value="Reset" class="btnBlue left btnReset" />
                <div id="selectAction" class="right">
                    <?php echo fx_control::newInstance('selectMassAction')
								 ->createType('option')
								 ->addOption('', '')
								 ->addOption('Active', site_url("admin/catalog/chapter/massActive", true))
								 ->addOption('Deactive', site_url("admin/catalog/chapter/massDeactive", true))
								 ->addClass('massSelectAction')
								 ->addClass('stdSelect')
								 ->render(); 
					?>
					<input type="button" class="btnBlue" id="btnActiveAction" value="Action" onclick="activeMassAction('frmChapterGridView', 'selectMassAction')" />
                </div>
            </div>
            <div class="pagination">
                <div class="results">
                    <span>showing results <?php echo $pagData->firstItemNumber ?>-<?php echo $pagData->lastItemNumber ?> of <?php echo $found ?></span>
                </div>
                <div class="page">
                    <ul>
                        <?php if ($paginator->getCurrentPageNumber() <= 1) : ?>
                            <li><a>« Previous</a></li>
                        <?php else : ?>
                            <li><a href="#" onclick="prevPage('chapterPageIndex', 'frmChapterGridView')">« Previous</a></li>
                        <?php endif; ?>
                        <?php foreach ($pagData->pagesInRange as $pageIndex) : ?>
                            <li <?php if ($pagData->current == $pageIndex) echo 'class="current"' ?>>
                                <a class="pageIndexValue" href="#"><?php echo $pageIndex ?></a>
                            </li>
                        <?php endforeach; ?>
                        <?php if ($paginator->getCurrentPageNumber() >= $paginator->count()) : ?>
                            <li><a>Next »</a></li>
                        <?php else : ?>
                            <li><a href="#" onclick="nextPage('chapterPageIndex', 'frmChapterGridView', <?php echo $paginator->count() ?>)">Next »</a></li>
                        <?php endif; ?>
                    </ul>
                </div>
            </div>
            <div id="table">
                <table id="gridview">
                    <thead>
                        <tr class="columns">
                            <input type="hidden" name="chapterOrder[name]" value="<?php echo $sorter->getName() ?>" id="chapterOrder"/>
                            <input type="hidden" name="chapterOrder[direction]" value="<?php echo $sorter->getDirection() ?>" id="chapterOrderDirection"/>
                            <th></th>
                            <th class="columnFilter" id="chapter_id">ID</th>
                            <th class="txtLeft columnFilter" id="chapter_name">Number</th>
                            <th class="txtLeft columnFilter" id="chapter_summary">Chapter</th>
                            <th>Action</th>
                        </tr>
                        <tr class="filters">
                            <td colspan="2" width="10%"></td>
                            <td width="40%">
                                <input type="text" name="chapterFilter[number][value]" class="hardtv-input-style-2" value="<?php echo $filters->getValue('number'); ?>" style="width:98%"/>
                                <input type="hidden" name="chapterFilter[number][type]" value="string"/>
                            </td>
                            <td width="30%">
                                <input type="text" name="chapterFilter[chapter][value]" class="hardtv-input-style-2" value="<?php echo $filters->getValue('chapter'); ?>" style="width:98%"/>
                                <input type="hidden" name="chapterFilter[chapter][type]" value="string"/>
                            </td>
                            <td width="20%"></td>
                        </tr>
                    </thead>
                    <tbody>
                    <?php foreach ($collection as $chapter) : ?>
                        <tr id="row_<?php echo $chapter->getId() ?>" class="activeRow">
                            <input class="editUrl" type="hidden" value="<?php echo $chapter->getChapterUrl(); ?>" />
                            <td class="select noActiveRow">
                                <?php echo fx_control::newInstance('chapter_checkbox[]')
												 ->createType('checkbox')
												 ->value($chapter->getId())
												 ->addClass('chkChapter')
												 ->removeClass('inputText')
												 ->bindingCheckbox($chapter_ids_array)
												 ->render();
								?>
                            </td>
                            <td><?php echo $chapter->getId() ?></td>
                            <td>
                            	<?php echo $chapter->getNumber() ?>
                           	</td>
                            <td><?php echo $chapter->getChapter() ?></td>
                            <td class="action noActiveRow">
                            	<a class="flashEditor" href="<?php echo site_url('admin/catalog/chapter/edit/id/' . $chapter->getId(), true) ?>"><span>Edit</span></a></li>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
            <div class="pagination">
                <div class="results">
                    <span>showing results <?php echo $pagData->firstItemNumber ?>-<?php echo $pagData->lastItemNumber ?> of <?php echo $found ?></span>
                </div>
                <div class="page">
                    <ul>
                        <?php if ($paginator->getCurrentPageNumber() <= 1) : ?>
                            <li><a>« Previous</a></li>
                        <?php else : ?>
                            <li><a href="#" onclick="prevPage('chapterPageIndex', 'frmChapterGridView')">« Previous</a></li>
                        <?php endif; ?>
                        <?php foreach ($pagData->pagesInRange as $pageIndex) : ?>
                            <li <?php if ($pagData->current == $pageIndex) echo 'class="current"' ?>>
                                <a class="pageIndexValue" href="#"><?php echo $pageIndex ?></a>
                            </li>
                        <?php endforeach; ?>
                        <?php if ($paginator->getCurrentPageNumber() >= $paginator->count()) : ?>
                            <li><a>Next »</a></li>
                        <?php else : ?>
                            <li><a href="#" onclick="nextPage('chapterPageIndex', 'frmChapterGridView', <?php echo $paginator->count() ?>)">Next »</a></li>
                        <?php endif; ?>
                    </ul>
                </div>
            </div>
        </div>
    </div>
<?php echo form_close(); ?>
<script language="javascript" type="text/javascript">
    jQuery("#gridview")
    .decorateTable()
    .lightHoverRow()
    .activePageIndex('pageIndexValue', 'chapterPageIndex', 'frmChapterGridView')
    .activeSortableAbility("frmChapterGridView", "columnFilter", "chapter_", "chapterOrder", "chapterOrderDirection")
    .checkboxCallbackHandler('chkChapter', 'chapter_ids', 'chapterItemSelected', 'chapterSelectedValueHidden')
    .activeResetButton('frmChapterGridView', 'btnReset', '<?php echo site_url('admin/catalog/chapter/index', true)?>')
    .activeColorBox('flashEditor');
</script>